/*
 * 创建日期 2005-10-5
 *
 * 更改所生成文件模板为
 * 窗口 > 首选项 > Java > 代码生成 > 代码和注释
 */
package com.vanda.report.view;

import com.vanda.report.ExcelUtils;
import com.vanda.report.ReportException;
import com.vanda.report.ReportInnerData;
import com.vanda.report.element.Element;
/**
 * 重定向标签 <br>
 * <p>
 * 
 * @author eagle <br>
 * @version Version 1.00 <br>
 */
public class RedirectionElement extends Element{
	/** 指定当前列数，从'A'开始，如不指定，默认为'A' */ 
	private String start_col;
	/** 指定当前行数，从1开始，如不指定，则为当前行 */
	private int start_row;
	/** 指定行数偏移量，则当前行数=原当前行数+row_offset*/
	private int row_offset;
	
	public void validator() throws ReportException{
	}
	
	/**
	 * 标签执行方法，递归执行
	 * @param obj
	 */
	public void execute(Object obj) throws ReportException{
		ReportInnerData reportData = (ReportInnerData)obj;
		try{
			//设置起始列和起始行
			if(start_col == null){
				start_col = "A";
			}
			reportData.setStart_col(ExcelUtils.getColIndex(start_col));
			reportData.setStart_row(start_row);
			if(start_row > 0)
				reportData.setCurrentRow(start_row-1);
			if(row_offset != 0){
				int currentRow = reportData.getCurrentRow() + row_offset;
				reportData.setCurrentRow(currentRow);
			}
			reportData.setContextData(reportData.getContextData());
			reportData.setFormatRowNum(0);
			
			super.execute(obj);
		}catch(ReportException e){
			throw e;
		}catch(Exception e){
			throw new ReportException(e);
		}

	}


	/**
	 * @return
	 */
	public String getStart_col() {
		return start_col;
	}

	/**
	 * @param i
	 */
	public void setStart_col(String i) {
		start_col = i;
	}

	/**
	 * @return
	 */
	public int getStart_row() {
		return start_row;
	}

	/**
	 * @param i
	 */
	public void setStart_row(int i) {
		start_row = i;
	}



	/**
	 * @return
	 */
	public int getRow_offset() {
		return row_offset;
	}

	/**
	 * @param i
	 */
	public void setRow_offset(int i) {
		row_offset = i;
	}

}
